Skip to content

refactor(config): centralize configuration precedence with reusable ConfigResolver#120

Open
kangeunchan wants to merge 1 commit intoaltuslabsxyz:mainfrom
kangeunchan:refactor/centralize-config-resolution
Open

refactor(config): centralize configuration precedence with reusable ConfigResolver#120
kangeunchan wants to merge 1 commit intoaltuslabsxyz:mainfrom
kangeunchan:refactor/centralize-config-resolution

Conversation

@kangeunchan
Copy link
Collaborator

Enhancement Description

Centralize configuration precedence with a reusable ConfigResolver to remove duplicated merge logic and inconsistent behavior.

Summary

This PR introduces a single config resolution path that applies the same precedence across command entry points.

Previously, config merge logic was duplicated and could diverge by command path:

  • some paths resolved flags/env/file/defaults in different orders
  • fallback behavior and effective config calculation were not fully shared
  • review and testing costs increased because precedence logic was scattered

Now all targeted paths use one shared resolver with deterministic precedence.

What Changed

1) Added reusable ConfigResolver (SSOT)

Added shared precedence resolution in:

  • internal/config/resolver.go
  • internal/config/resolver_test.go

Precedence rule:

  • flags > env > file > defaults

2) Migrated command call sites to shared resolver

Updated:

  • cmd/devnet-builder/commands/root.go
  • cmd/devnet-builder/commands/core/init.go
  • cmd/devnet-builder/commands/manage/deploy.go

All paths now resolve effective config through the same resolver API.

3) Preserved behavior while removing duplication

  • no new flags were introduced
  • no CLI contract changes were introduced
  • error handling and effective values are now consistent by design

4) Tests

Added/updated tests:

  • internal/config/resolver_test.go

Why This Is Needed

This is a consistency and maintainability refactor.
A single resolver prevents precedence drift, reduces hidden differences between commands, and makes behavior easier to validate.

Behavior Notes / Regression Impact

No intentional user-facing behavior change.
The key change is deterministic and shared precedence handling across all integrated paths.

Validation Performed

  • go test ./internal/config/...
  • go test ./cmd/devnet-builder/commands/...
  • go test ./...
  • golangci-lint run

Signed-off-by: kangeunchan <kangeunchan080310@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant